import {NgModule} from '@angular/core';
import {PreloadAllModules, RouterModule, Routes} from '@angular/router';

// 组件
import {LoginComponent} from './pages/login/login.component';
import {IonicModule} from '@ionic/angular';
import {FormsModule} from '@angular/forms';
import {ValidationGuard} from './guard/validation/validation.guard';

const routes: Routes = [
    // tabs
    {
        path: '',
        loadChildren: () => import('./tabs/tabs.module').then(m => m.TabsPageModule),
        canActivate: [ValidationGuard],
    },
    // login
    {
        path: 'login',
        component: LoginComponent
    },
    // demo
    {
        path: 'home-open',
        loadChildren: () => import('./router/demo/demo.module').then(m => m.DemoModule),
        canActivate: [ValidationGuard],
    },
    // redirect To
    {
        path: '**',
        redirectTo: ''
    }
];

@NgModule({
    imports: [
        RouterModule.forRoot(routes, {preloadingStrategy: PreloadAllModules}),
        IonicModule,
        FormsModule
    ],
    declarations: [LoginComponent],
    exports: [RouterModule]
})
export class AppRoutingModule {
}
